package com.block.api.controller.merchant;

import com.alibaba.fastjson.JSONObject;
import com.block.common.bean.CommonParam;
import com.block.common.exception.ApiException;
import com.block.common.security.util.ApiUtil;
import com.block.common.vo.ResponseVo;
import com.block.db.entity.AppEncrypt;
import com.block.db.entity.MerchantCheckInfo;
import com.market.member.service.IMerchantCheckInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("api/merchant")
@Validated
public class MerchantCheckController {


    @Autowired
    private IMerchantCheckInfoService merchantCheckInfoService;

    /**
     * 测试撞库境外电话
     */
    @RequestMapping(value = "/testCheck", method = {RequestMethod.POST, RequestMethod.GET})
    public String testCheck(@RequestAttribute(value = "tranData") JSONObject tranData,
                            @RequestAttribute(value = "appEncrypt") AppEncrypt appEncrypt,
                            @RequestAttribute(value = "uri") String uri,
                            @RequestAttribute(value = "commonParam") CommonParam commonParam,
                            @RequestAttribute(value = "startDate") Date startdate,
                            @RequestAttribute(value = "ip") String ip)  throws Exception {

        String realName = tranData.getString("realName");
        Integer infoId = tranData.getInteger("infoId");
        String city = tranData.getString("city");
        String idCard = tranData.getString("idCard");
        String mobile = tranData.getString("mobile");
        //String remarks = tranData.getString("remarks");
        MerchantCheckInfo merchantCheckInfo = new MerchantCheckInfo();
        merchantCheckInfo.setInfoId(infoId);
        merchantCheckInfo.setCity(city);
        merchantCheckInfo.setMobile(mobile);
        merchantCheckInfo.setIdCard(idCard);
        merchantCheckInfo.setRealName(realName);
        //merchantCheckInfo.setRemarks(remarks);
        ResponseVo responseVo = merchantCheckInfoService.testCheck(merchantCheckInfo);
        return ApiUtil.dealReturnJson(responseVo, appEncrypt, startdate, uri);
    }

}
